package main

import (
	"fmt"
	"sync"
	"time"
)

var wg sync.WaitGroup

func main() {
	chan1 := make(chan int)
	chan2 := make(chan int)

	wg.Add(1)
	go func() {
		defer close(chan1)
		chan1 <- 1
		time.Sleep(3 * time.Second)
		wg.Done()

	}()

	wg.Add(1)
	go func() {
		defer close(chan2)
		chan2 <- 1
		time.Sleep(5 * time.Second)
		wg.Done()

	}()
	for i := 0; i < 5; i++ {
		select {
		case <-chan1:
			fmt.Println("chan1:==>")
		case <-chan2:
			fmt.Println("chan2:==>")
		}
		wg.Wait()
	}

}
